package cn.com.open.itembank.service;

import cn.com.open.itembank.dto.PaperModel;
import cn.com.open.itembank.dto.RuleSaveModel;
import cn.com.open.itembank.dto.TestPaperForFullEdit;
import cn.com.open.itembank.dto.TestPaperModel;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

/**
 * Created by lucky on 2017/10/30.
 */
@FeignClient(name = "item-qti-service")
public interface QtiRemoteService {

    /**
     * 根据试卷模型得到空试卷xml.
     *
     * 返回map说明：
     * xml=试卷qti的xml;
     * score=试卷总分;
     * exist=操作的数据是否存在;
     *
     * @param paper 试卷模型
     * @return 试卷返回数据map new paper xml
     * @throws Exception the exception
     */
    @PostMapping(value = "/openqti/testpaper/getNewPaperXml")
    Map<String, Object> getNewPaperXml(@RequestBody PaperModel paper);

    /**
     * 根据试题模型得到试题标题.
     *
     * @param orginalXml the orginal xml
     * @param title      the title
     * @return the xml
     */
    @PostMapping(value = "/openqti/testpaper/getEditTitleXml")
    Map<String, Object> getEditTitleXml(@RequestBody String orginalXml, @RequestParam("title") String title);

    /**
     * 从xml转换试卷模型实体.
     *
     * @param orginalXml 试卷xml
     * @return the test paper
     * @throws Exception the exception
     */
    @PostMapping(value = "/openqti/testpaper/get")
    TestPaperModel get(@RequestBody String orginalXml);

    /**
     * 得到删除大题的试卷xml.
     *
     * 返回map说明：
     * xml=试卷qti的xml;
     * score=试卷总分;
     * exist=操作的数据是否存在;
     *
     * @param orginalXml 删除前的试卷xml
     * @param sectionId  要删除的大题id
     * @return 试卷返回数据map remove section xml
     * @throws Exception the exception
     */
    @PostMapping(value = "/openqti/testpaper/getRemoveSectionXml")
    Map<String, Object> getRemoveSectionXml(@RequestBody String orginalXml, @RequestParam("sectionId") String sectionId);

    /**
     * 得到删除试题的试卷xml.
     *
     * 返回map说明：
     * xml=试卷qti的xml;
     * score=试卷总分;
     * exist=操作的数据是否存在;
     *
     * @param orginalXml 删除前的试卷xml
     * @param questionId 要删除的试题id
     * @return 试卷返回数据map remove question xml
     * @throws Exception the exception
     */
    @PostMapping(value = "/openqti/testpaper/getRemoveQuestionXml")
    Map<String, Object> getRemoveQuestionXml(@RequestBody String orginalXml, @RequestParam("questionId") String questionId);

    /**
     * 得到修改大题的试卷xml.
     * <p>
     * 输入参数说明：Object/String
     * Object/String
     * String/xml
     * Section/section
     * <p>
     * 返回map说明：
     * xml=试卷qti的xml;
     * score=试卷总分;
     * exist=操作的数据是否存在;
     *
     * @param info 请求模型
     * @return 试卷返回数据map edit section xml
     * @throws Exception the exception
     */
    @PostMapping(value = "/openqti/testpaper/getEditSectionXml")
    Map<String, Object> getEditSectionXml(@RequestBody Map<String, Object> info);

    /**
     * 得到修改大题试题分数的试卷xml.
     * <p>
     * 返回map说明：
     * xml=试卷qti的xml;
     * score=试卷总分;
     * exist=操作的数据是否存在;
     *
     * @param orginalXml 修改前的试卷xml
     * @param sectionId  要修改的大题id
     * @param questionId 要修改的试题id，如果修改大题所有试题分数，此字段为空即可
     * @param score      要修改的试题分数
     * @return 试卷返回数据map edit section score xml
     * @throws Exception the exception
     */
    @PostMapping(value = "/openqti/testpaper/getEditSectionScoreXml")
    Map<String, Object> getEditSectionScoreXml(@RequestBody String orginalXml, @RequestParam("sectionId") String sectionId,
                                                             @RequestParam("questionId") String questionId, @RequestParam("score") double score);


    /**
     * 得到移动试题顺序的试卷xml.
     * <p>
     * 返回map说明：
     * xml=试卷qti的xml;
     * score=试卷总分;
     * exist=操作的数据是否存在;
     *
     * @param orginalXml 修改前的试卷xml
     * @param sectionId  要移动的大题id
     * @param questionId 要移动的试题id
     * @param m          移动方式：上移/下移：t/f
     * @return 试卷返回数据map edit section xml
     * @throws Exception the exception
     */
    @PostMapping(value = "/openqti/testpaper/getMoveQuestionXml")
    Map<String, Object> getMoveQuestionXml(@RequestBody String orginalXml, @RequestParam("sectionId") String sectionId,
                                                         @RequestParam("questionId") String questionId, @RequestParam("m") boolean m);


    /**
     * 得到移动大题顺序的试卷xml.
     * <p>
     * 返回map说明：
     * xml=试卷qti的xml;
     * score=试卷总分;
     * exist=操作的数据是否存在;
     *
     * @param orginalXml 修改前的试卷xml
     * @param sectionId  要移动的大题id
     * @param m          移动方式：上移/下移：t/f
     * @return 试卷返回数据map edit section xml
     * @throws Exception the exception
     */
    @PostMapping(value = "/openqti/testpaper/getMoveSectionXml")
    Map<String, Object> getMoveSectionXml(@RequestBody String orginalXml, @RequestParam("sectionId") String sectionId,
                                           @RequestParam("m") boolean m);
    /**
     * 根据策略模型得到xml.
     *
     * @param ruleInputModel the rules
     * @return the full qti xml
     * @throws Exception the exception
     */
    @PostMapping(value = "/openqti/rules/getFullQtiXml")
    String getFullQtiXml(@RequestBody RuleSaveModel ruleInputModel);


    /**
     * 根据xml构造策略模型实体.
     *
     * @param orginalXml the orginal xml
     * @return the rules
     * @throws Exception the exception
     */
    @PostMapping(value = "/openqti/rules/get")
    RuleSaveModel getObjectByXml(@RequestBody String orginalXml);

    /**
     * 得到新增试题的试卷xml.
     * <p>
     * 输入参数说明：Object/String
     * String/xml
     * Section/section
     * String/questionId
     * double/score
     * ItemType/itemType
     * <p>
     * 返回map说明：
     * xml=试卷qti的xml;
     * score=试卷总分;
     * exist=操作的数据是否存在;
     *
     * @param info 请求模型
     * @return 试卷返回数据map add question xml
     * @throws Exception the exception
     */
    @PostMapping(value = "/openqti/testpaper/getAddQuestionXml")
    Map<String, Object> getAddQuestionXml(@RequestBody Map<String, Object> info);


    /**
     * 得到复制试卷xml.
     *
     * @param orginalXml     被复制的试卷xml
     * @param newTestPaperId 新的试卷id
     * @return the copy test paper xml
     * @throws Exception the exception
     */
    @PostMapping(value = "/openqti/testpaper/getCopyTestPaperXml")
    Map<String, Object> getCopyTestPaperXml(@RequestBody String orginalXml, @RequestParam("newId") String newTestPaperId);

    /**
     * 得到修改试题的试卷xml.
     * <p>
     * 输入参数说明：Object/String
     * Object/String
     * String/xml
     * Section/section
     * String/questionId
     * String/newQuestionId
     * double/score
     * ItemType/itemType
     * <p>
     * 返回map说明：
     * xml=试卷qti的xml;
     * score=试卷总分;
     * exist=操作的数据是否存在;
     *
     * @param info 请求模型
     * @return 试卷返回数据map add question xml
     * @throws Exception the exception
     */
    @PostMapping(value = "/openqti/testpaper/getEditQuestionXml")
    Map<String, Object> getEditQuestionXml(@RequestBody Map<String, Object> info);

    /**
     * 根据试卷模型得到试卷xml.
     *
     * @param paper the paper
     * @return the full paper xml
     * @throws Exception the exception
     */
    @PostMapping(value = "/openqti/testpaper/getFullPaperXml")
    Map<String, Object> getFullPaperXml(@RequestBody TestPaperModel paper);

    /**
     * 根据试卷模型得到试卷xml.
     *
     * @param info the info
     * @return the full paper xml
     * @throws Exception the exception
     */
    @PostMapping(value = "/openqti/testpaper/getFullPaperXmlWithExistXml")
    Map<String, Object> getFullPaperXmlWithExistXml(@RequestBody TestPaperForFullEdit info);

}